<?php
session_start();

$ran_str = md5(microtime());
$first = substr($ran_str, 0, 2);
$second = substr($ran_str, 5, 3);
$ran_str = $first . ' ' . $second ;

$_SESSION['cap_code'] = $ran_str;

$font = 'font/times_new_yorker.ttf';

$captcha_img = imagecreatefromjpeg("cap_bg.jpg");

$white = imagecolorallocate($captcha_img, 255, 255, 255);
$grey = imagecolorallocate($captcha_img, 128, 128, 128);
$black = imagecolorallocate($captcha_img, 0, 0, 0);

$shadow = rand(-10, 10);
$real = rand(-10, 10);

$color = imagecolorallocate($captcha_img, 0, 50, 160);
imagettftext($captcha_img, 15, $shadow, 11, 21, $grey, $font, $ran_str);

imagettftext($captcha_img, 15, $real, 11, 21, $color, $font, $ran_str);

header("Content-type: image/jpeg");
imagejpeg($captcha_img);
imagedestroy($captcha_img);
?>


